package com.gph.saviorframework.security.service.impl;

import com.gph.saviorframework.common.model.PositionLevel;
import com.gph.saviorframework.dao.security.PositionLevelDao;
import com.gph.saviorframework.security.service.PositionLevelService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class PositionLevelServiceImpl implements PositionLevelService {

    @Autowired
    private PositionLevelDao positionLevelDao;

    /**
     * 保存
     *
     * @param positionLevel
     */
    public void save(PositionLevel positionLevel) {
        positionLevelDao.save(positionLevel);
    }

    /**
     * 根据编号获取
     *
     * @param id
     * @return
     */
    public PositionLevel get(String id) {
        return positionLevelDao.get(id);
    }

    /**
     * 更新
     *
     * @param positionLevel
     * @return
     */
    public void update(PositionLevel positionLevel) {
        positionLevelDao.update(positionLevel);
    }

    /**
     * 批量更新
     *
     * @param positionLevels
     */
    @Override
    public void update(Set<PositionLevel> positionLevels) {
        for(PositionLevel positionLevel : positionLevels){
            update(positionLevel);
        }
    }

    /**
     * 根据条件返回数据
     *
     * @param sort
     * @param dir
     * @param params
     * @return
     */
    public List<Map<String, Object>> find(String sort, String dir, Map<String, Object> params) {
        String whereClause = "1=1";
        return positionLevelDao.find(sort, dir, whereClause);
    }

    /**
     * 带分页参数的，给bootstrap使用的
     *
     * @param start  开始页码，从1开始
     * @param limit  每页查询的次数
     * @param sort
     * @param dir
     * @param params
     * @return
     */
    @Override
    public Map<String, Object> find(int start, int limit, String sort, String dir, Map<String, Object> params,Object... extras) {
        return null;
    }

    /**
     * 统计数量
     *
     * @param params
     * @return
     */
    public long count(Map<String, Object> params) {
        return 0;
    }

    /**
     * 根据主键删除
     *
     * @param id
     */
    public void delete(String id) {

    }

    /**
     * 批量删除
     *
     * @param ids
     */
    public void deleteByIds(String[] ids) {

    }

    /**
     * 查询字段集合
     *
     * @return
     */
    public Map<String, String> getFields() {
        return null;
    }

    /**
     * 根据id查询map
     *
     * @param id
     * @return
     */
    public Map<String, Object> findById(String id) {
        return null;
    }

    /**
     * 生成where条件
     *
     * @param params
     * @param extra
     * @return
     */
    public String genWhereClause(Map<String, Object> params, Object... extra) {
        return null;
    }

    public List<Map<String, Object>> findByPosition(String positionId) {
        return positionLevelDao.findByPosition(positionId);
    }
}
